1. Technical Field
This disclosure relates generally to heap fragmentation in a data processing system and more specifically to allocation aware heap fragmentation metrics in the data processing system.
2. Description of the Related Art
Garbage collectors (GC) and associated allocators typically view free memory statically as a collection of free entries in a heap. When a predetermined set of free memory entries are small in size, the memory is considered fragmented. When fragmentation exceeds a predetermined threshold, garbage collectors may decide to de-fragment the memory, typically by compacting live objects in the memory. Commercially available garbage collectors use various compaction triggers including when a percentage of free memory after a collection is determined to be less than a predetermined percentage and an inability to allocate a large object, although having a sufficient amount of free memory according to an average size of thread-local-heap allocated between two garbage collector cycles.
In another current example of garbage collection, scheduling and managing which area of heap to be used for allocation is a focus. In another example a garbage collector focuses on compaction rather than fragmentation. Another example deals with allocation, and methods to at least minimize fragmentation and a need for compaction.
The triggers also referred to as fragmentation metrics are not sufficiently dynamic and are typically invoked too late. The triggers also typically have little or no knowledge of how a particular application (allocation) behaves with respect to memory usage. The triggers observe fragmentation only after a serious problem is detected.
There is a need for a trigger that can predict problems associated with memory allocation before the problems occur. Modern garbage collectors typically rely on accurate scheduling of concurrent global garbage collection, which in turn also relies heavily on accurate information regarding available free memory as the allocation process progresses. When concurrent garbage collection is not able to finish before free memory is exhausted, a garbage collector is required to perform relatively expensive operations including abort of local garbage collection, complete global collection using a stop-the-world mode, and typically perform a global compaction. When memory is fragmented, not all statically available memory can be used as input information for concurrent garbage collector scheduling. The available memory therefore has to be reduced by an amount of memory that is fragmented. To accurately identify the fragmented memory, a better metric is required.